#include "type.h"

int contains(c, line) char c; char* line;
{
	while(*line != 0)
	{
		if (*(line++) == c) { return 1; }
	}
	return 0;
}

int do_getpid()
{
   return syscall(0,0,0);
}

int do_kmode()
{
   return syscall(3, 0, 0);
}    

int do_kswitch()
{
   return syscall(4,0,0);
}

int do_fork()
{  
   return syscall(5, 0, 0);
}

int do_exec(cmdline) char *cmdline;
{
   return syscall(6, cmdline, 0);
}

int do_wait(status) int *status;
{
   return syscall(20, status, 0);
}

int do_mkdir(name) char *name;
{
   return syscall(21, name, 0);
}

int do_rmdir(name) char *name;
{
   return syscall(22, name, 0);
}

int do_creat(name) char *name;
{
   return syscall(23, name, 0);
}

int do_rm(name) char *name;
{
   return syscall(24, name, 0);
}

int do_chdir(name) char *name;
{
    return syscall(26, name, 0);
}

int do_open(file, flag) char *file; int flag;
{
    return syscall(28, file, flag);
}

int do_close(fd) int fd;
{
    return syscall(29, fd);
}

long do_lseek(fd, offset, ww) int fd; long offset; int ww;
{
    return syscall(30, fd, (long)offset, ww);
}

int do_chmod(mode,file) int mode; char *file;
{
  return syscall(33, mode, file, 0);
}   

int do_chown(uid) int uid;
{
    return syscall(34, uid, 0);
}   

int do_read(fd, buf, nbytes) int fd, nbytes; char *buf;
{
    return syscall(35, fd, buf, nbytes);
}

int do_write(fd, buf, nbytes) int fd, nbytes; char *buf;
{
    return syscall(36, fd, buf, nbytes);
}

int do_stat(filename, sPtr) char *filename; struct stat *sPtr;
{   
   return syscall(38, filename, sPtr);
}

int do_getcwd(cwdname) char *cwdname;
{
    return syscall(39, cwdname, 0);
}

int do_pipe(pd) int *pd;
{
    return syscall(40, pd, 0);
}

int do_dup(fd) int fd;
{
    return syscall(41, fd, 0);
}

int do_dup2(fd,gd) int fd, gd;
{
    return syscall(42, fd, gd);
}

int do_kps()
{
   return syscall(43,0,0);
}

int do_getuid()
{
  return syscall(44, 0, 0);
}

int do_setuid(uid) int uid;
{
  return syscall(45, uid, 0);
}

int do_gettty(s) char *s;
{
  return syscall(46, s, 0);
}

int do_settty(s) char *s;
{
  return syscall(47, s, 0);
}

int do_fstat(fd, sptr) int fd; struct stat *sptr;
{
    return syscall(48, fd, sptr, 0);
}

int do_kill(sig, pid) int sig, pid;
{
    return syscall(50, sig, pid);
}

int do_signal(sig, catcher) ushort sig, catcher;
{
  return syscall(51, sig, catcher);
}

int do_sleep(t) ushort t;
{
  return syscall(52, t, 0);
}

int do_timer(t) ushort t;
{
  return syscall(53, t, 0);
}

int do_sync()
{
  return syscall(90,0,0);
}

int do_hitratio(requests, hits) int *requests, *hits;
{
  return syscall(96, requests, hits);
}

int do_exit(exitValue) int exitValue;
{
   syscall(99, exitValue, 0);
}

int do_pwd()
{
  char cwd[64];
  getcwd(cwd);
  printf("%s\n", cwd);
}

int do_getchar()
{
  return getc();
}
